package mid;

import java.util.HashMap;

public class a205_同构字符串 {
    public boolean isIsomorphic(String s, String t) {
        if (s.length() != t.length()) {
            return false;
        }
        HashMap<Character, Character> hashMap = new HashMap<>();
        for (int i = 0; i < s.length(); i++) {
            if(!hashMap.containsKey(s.charAt(i))) {
                if (hashMap.containsValue(t.charAt(i))) {
                    return false;
                }
                hashMap.put(s.charAt(i),t.charAt(i));
            }
            if (hashMap.get(s.charAt(i))!=t.charAt(i)){
                return false;
            }
        }
        return true;
    }
}
